package generics;

public class MyGenerics<E> {

	private Integer d = 2;
	
	public String parse(E e){
		return e.toString();
	}

	public E getInstance() throws Exception {
		try {
			E d2 = (E) d;
			return d2;
		} catch (Exception e) {
			throw new Exception("Casting error.");
		}
	}

	public static void main(String[] args) {
		MyGenerics<Integer> g = new MyGenerics<Integer>();
		try {
			Integer x = g.getInstance();
			System.out.println(x.getClass() + " " + x.toString());
			System.out.println(g.parse(1234));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
